[mdadm PATCH] Fix small memory leak
Credit goes to cppcheck.
Signed-off-by: Thomas Jarosch <thomas.jarosch [at] intra2net.com>
---
policy.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/policy.c b/policy.c
index 2bbbac8..4a6ef82 100644
--- a/policy.c
+++ b/policy.c
[at] [at] -757,8 +757,10 [at] [at] int policy_check_path(struct mdinfo *disk, struct map_ent *array)
snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path);
f = fopen(path, "r");
- if (!f)
+ if (!f) {
+ free(id_path);
return 0;
+ }
rv = fscanf(f, " %s %x:%x:%x:%x\n",
array->metadata,
[at] [at] -767,6 +769,7 [at] [at] int policy_check_path(struct mdinfo *disk, struct map_ent *array)
array->uuid+2,
array->uuid+3);
fclose(f);
+ free(id_path);
return rv == 5;
}
--
1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [mdadm PATCH] Fix small memory leak
--Sig_/J8fyedvHsN7D2dhjWDGRl.s
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
On Sun, 02 Oct 2011 21:45:41 +0200 Thomas Jarosch
<thomas.jarosch [at] intra2net.com> wrote:
> Credit goes to cppcheck.
>
> Signed-off-by: Thomas Jarosch <thomas.jarosch [at] intra2net.com>
> ---
> policy.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/policy.c b/policy.c
> index 2bbbac8..4a6ef82 100644
> --- a/policy.c
> +++ b/policy.c
> [at] [at] -757,8 +757,10 [at] [at] int policy_check_path(struct mdinfo *disk, struct ma=
p_ent *array)
>
> snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path);
> f =3D fopen(path, "r");
> - if (!f)
> + if (!f) {
> + free(id_path);
> return 0;
> + }
>
> rv =3D fscanf(f, " %s %x:%x:%x:%x\n",
> array->metadata,
> [at] [at] -767,6 +769,7 [at] [at] int policy_check_path(struct mdinfo *disk, struct map=
_ent *array)
> array->uuid+2,
> array->uuid+3);
> fclose(f);
> + free(id_path);
> return rv =3D=3D 5;
> }
>
applied. Thanks.
NeilBrown
--Sig_/J8fyedvHsN7D2dhjWDGRl.s
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
iD8DBQFOiNgvG5fc6gV+Wb0RAjKlAKCrUdwnh+B5gNKomblesz9c5XNt3gCf aD4t
5dweZ+sWis0HPWrPjMkFuzo=
=dNVl
-----END PGP SIGNATURE-----
--Sig_/J8fyedvHsN7D2dhjWDGRl.s--
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html